home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209b.zip / octave-2.09 / SCRIPTS.ZIP / scripts / plot / __plt__.m < prev    next >
Text File  |  1997-01-29  |  2KB  |  113 lines

  1. ## Copyright (C) 1996 John W. Eaton
  2. ##
  3. ## This file is part of Octave.
  4. ##
  5. ## Octave is free software; you can redistribute it and/or modify it
  6. ## under the terms of the GNU General Public License as published by
  7. ## the Free Software Foundation; either version 2, or (at your option)
  8. ## any later version.
  9. ##
  10. ## Octave is distributed in the hope that it will be useful, but
  11. ## WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. ## General Public License for more details.
  14. ##
  15. ## You should have received a copy of the GNU General Public License
  16. ## along with Octave; see the file COPYING.  If not, write to the Free
  17. ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  18. ## 02111-1307, USA.
  19.  
  20. ## Author: jwe
  21.  
  22. function __plt__ (caller, ...)
  23.  
  24.   if (nargin == 2)
  25.  
  26.     __plt1__ (va_arg (), "");
  27.  
  28.   elseif (nargin > 2)
  29.  
  30.     first_plot = 1;
  31.     hold_state = ishold ();
  32.  
  33.     unwind_protect
  34.  
  35.       x = va_arg ();
  36.       nargin = nargin - 2;
  37.       x_set = 1;
  38.       y_set = 0;
  39.  
  40.       ## Gather arguments, decode format, and plot lines.
  41.  
  42.       while (nargin-- > 0)
  43.  
  44.     fmt = "";
  45.     new = va_arg ();
  46.  
  47.     if (isstr (new))
  48.       if (! x_set)
  49.         error ("plot: no data to plot");
  50.       endif
  51.       fmt = __pltopt__ (caller, new);
  52.       if (! y_set)
  53.         __plt1__ (x, fmt);
  54.       else
  55.         __plt2__ (x, y, fmt);
  56.       endif
  57.       hold on;
  58.       x_set = 0;
  59.       y_set = 0;
  60.     elseif (x_set)
  61.       if (y_set)
  62.         __plt2__ (x, y, fmt);
  63.         hold on;
  64.         x = new;
  65.         y_set = 0;
  66.       else
  67.         y = new;
  68.         y_set = 1;
  69.       endif
  70.     else
  71.       x = new;
  72.       x_set = 1;
  73.     endif
  74.  
  75.     ## Something fishy is going on.  I don't think this should be
  76.     ## necessary, but without it, sometimes not all the lines from a
  77.     ## given plot command appear on the screen.  Even with it, the
  78.     ## delay might not be long enough for some systems...
  79.  
  80.     usleep (1e5);
  81.  
  82.       endwhile
  83.  
  84.       ## Handle last plot.
  85.  
  86.       if  (x_set)
  87.     if (y_set)
  88.       __plt2__ (x, y, fmt);
  89.     else
  90.       __plt1__ (x, fmt);
  91.     endif
  92.       endif
  93.  
  94.     unwind_protect_cleanup
  95.  
  96.       if (! hold_state)
  97.         hold off;
  98.       endif
  99.  
  100.     end_unwind_protect
  101.  
  102.   else
  103.  
  104.     msg = sprintf ("%s (x)\n", caller);
  105.     msg = sprintf ("%s       %s (x, y)\n", msg, caller);
  106.     msg = sprintf ("%s       %s (x2, y1, x2, y2)\n", msg, caller);
  107.     msg = sprintf ("%s       %s (x, y, fmt)", msg, caller);
  108.     usage (msg);
  109.  
  110.   endif
  111.  
  112. endfunction
  113.